import os
from openai import OpenAI

s1 = """
public class Main {
    public static int test(int x, int y) {
        if (10 > x && x > 0 && x + y > 5) {
            return 1;
        } else {
            return -1;
        }
    }

    public static void main(String[] args) {
        // 示例调用
        int x = 3;
        int y = 3;
        int result = test(x, y);
        System.out.println("Result: " + result);
    }
}
"""

# s2 = """
# 将这段程序转为python语言（只返回代码即可）
# """
s2 = """
提取这段代码的约束条件,'&&'用','代替,并在最外层用'[]'包围（只返回约束条件即可）
"""

question = s1 + s2

client = OpenAI(
    api_key="sk-067ca2043e80470ba2313779960367f8",
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
    model="qwen-plus",
    # 模型列表：https://help.aliyun.com/zh/model-studio/getting-started/models
    messages=[
        {'role': 'system', 'content': 'You are a helpful assistant.'},
        {'role': 'user', 'content': question}],
)

# 解析返回的JSON数据并提取content字段
response_content = completion.choices[0].message.content
print(response_content)